<!DOCTYPE html>
<html>
<head>
  <title>订单详情</title>
  <meta name="renderer" content="webkit|ie-comp|ie-stand">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <!-- head 中 -->
  <link rel="stylesheet" th:href="@{/jquery-weui/lib/weui.css}">
  <link rel="stylesheet" th:href="@{/jquery-weui/css/jquery-weui.css}">
  <link rel="stylesheet" th:href="@{/jquery-weui/css/demos.css?t=12}">
  <style>
    html{
      height: 100%;

    }
    body{
      width: 100%;
      height:100%;
    }
    *{
      margin: 0;
      padding: 0;
    }
    .bd{
      width: 100%;
      height:90%;
      overflow-y: scroll;
    }
    /* 修改标题的文字大小 */
    .weui-dialog__title {
      font-size: 24px;
    }
    .weui-dialog__bd {
      font-size: 20px;
    }
    /* 修改按钮的文字大小和内边距 */
    .weui-dialog__btn {
      font-size: 20px;
      padding: 10px 20px;
    }
  </style>
</head>

<body>
<input id="receiverId" name="receiverId" type="hidden" value="">
<table style="height: 55px;width: 100%;background-color: #f3f3f3;">
  <tr><td colspan="3" height="5px;"></td></tr>
  <tr>
    <td style="width: 10%;text-align: center;">&nbsp;<img src="/stamp/image/ht.png" style="width: 25px;height: 25px;" onclick="window.history.back();">&nbsp;</td>
    <td style="width: 80%"></td>
    <td style="width: 10%;text-align: center">&nbsp;<img src="/stamp/image/sx.png" style="width: 25px;height: 25px;" onclick="window.location.reload()">&nbsp;</td>
  </tr>
</table>
<header class='demos-header'>
  <h1 class="demos-title">订单详情</h1>
</header>
<!--地址簿-->
<div id="addrPopup" class="weui-popup__container">
  <div class="weui-popup__overlay"></div>
  <div class="weui-popup__modal" style="background-color:#F0F0F0;">
    <iframe width="100%;" id="addr_iframe" height="100%;" style="border:none;" src=""></iframe>
  </div>
</div>
<div class="bd">
  <div class="page__bd">
    <div class="weui-cells__title">订单信息</div>
    <div class="weui-cells">
      <div class="weui-cell">
        <div class="weui-cell__hd"></div>
        <div class="weui-cell__bd">
          <p style="font-size:16pt;">数量</p>
        </div>
        <div class="weui-cell__ft" style="font-size:16pt;"><span id="mxpsl"></span>（张）</div>
      </div>
      <div class="weui-cell">
        <div class="weui-cell__hd"></div>
        <div class="weui-cell__bd">
          <p style="font-size:16pt;">制作费</p>
        </div>
        <div class="weui-cell__ft" style="font-size:16pt;"><span id="mxpjg"></span>（元）</div>
      </div>
      <div class="weui-cell" style="display: none">
        <div class="weui-cell__hd"></div>
        <div class="weui-cell__bd">
          <p>运费</p>
        </div>
        <div class="weui-cell__ft" style="font-size:16pt;"><span id="mxpyf"></span>（元）</div>
      </div>
      <div class="weui-cell">
        <div class="weui-cell__hd"><img src="/stamp/image/APP-02-04-shoujianren.png" style="width: 25px;height: 25px;"></div>
        <div class="weui-cell__bd" id="receive_div">

        </div>
        <span style="font-weight:100;color:gainsboro;">|&nbsp;</span><div id="receive_div_addrbook" class="weui-cell__ft" style="font-weight: bold;color:crimson;font-size: 11pt;">地址簿</div>
      </div>
    </div>
  </div>
  <div style="height: 50px"></div>
  <table style="width: 100%;height: 60px;">
    <tr>
      <td style="text-align: center">
        <a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary" style=";font-size:16pt;font-weight: bold" onclick="qrdd();">确认订单</a>&nbsp;&nbsp;
      </td>
    </tr>
  </table>
</div>
<!-- body 最后 -->
<script type="text/javascript" th:src="@{/jquery-weui/lib/jquery-2.1.4.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jquery-weui/lib/fastclick.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jquery-weui/js/jquery-weui.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jsfiles/crypto-js.min.js?t=1}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/jsfiles/com.js?t=12}" charset="utf-8"></script>
<script>
  $(function() {
    FastClick.attach(document.body);
  });
  var id = "[[${id}]]";
  var adminUrl = "[[${adminUrl}]]";
  //后端地址
  var url = "[[${serverUrl}]]/stamp/h5/api/";
  //图片显示
  var url1 = "[[${serverUrl}]]/stamp/tp/";

  var dz = window.location.href;
  dz = dz.replace(/&/g, "$");
  function init_data(){
    $.showLoading("数据加载中...");
    var jsonData = {
      id: id,
      timestamp:new Date().getTime()
    };
    var sendStr = {
      data:encrypt_str(JSON.stringify(jsonData),localStorage.getItem("a_h5"),localStorage.getItem("b_h5"))
    };
    $.ajax({
      type:"post",
      url:url+"order_info",
      data:JSON.stringify(sendStr),
      dataType:"json",
      timeout : 10*1000, //超时时间设置，单位毫秒
      crossDomain: true,
      contentType: 'application/json;charset=UTF-8',
      headers: {
        "token": localStorage.getItem("token_h5")
      },
      beforeSend: function(request) {
        request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
      },
      success:function(result){
        console.info("result:"+JSON.stringify(result));
        if (result.code==0) {
          let rtn = decrypt_str(result.data, localStorage.getItem("a_h5"), localStorage.getItem("b_h5"));
          let d = JSON.parse(rtn);
          $("#mxpsl").html(d.stampCardOrder.zsl);
          $("#mxpjg").html(d.stampCardOrder.jg);
          $("#mxpyf").html(d.stampCardOrder.yf);
          var str="";
          if (!is_null(d.stampCardOrder.fullDz)){
            str+=" <h4 class=\"weui-media-box__title\" style=\"font-weight: bold;font-size: 15pt;\" id=\"receiverName\">&nbsp;&nbsp;"+d.stampCardOrder.lxr+" 手机尾号："+d.stampCardOrder.lxdhJsm+"</h4>\n" +
                    "          <p class=\"weui-media-box__desc\" id=\"receiverAddr\" style=\"font-size: 12pt;\">&nbsp;&nbsp;<font>"+d.stampCardOrder.fullDz+"</font></p>";
            $("#receiverId").val("0");//0 不更新地址
          }else{
            if (!is_null(d.receiverAddr)){
              $("#receiverId").val(d.receiverAddr.lsh);
              str+=" <h4 class=\"weui-media-box__title\" style=\"font-weight: bold;font-size: 15pt;\" id=\"receiverName\">&nbsp;&nbsp;"+d.receiverAddr.name+" 手机尾号："+d.receiverAddr.telJsm+"</h4>\n" +
                      "          <p class=\"weui-media-box__desc\" id=\"receiverAddr\" style=\"font-size: 12pt;\">&nbsp;&nbsp;<font>"+d.receiverAddr.fullAddress+"</font></p>";
            }else{
              str+=" <h4 class=\"weui-media-box__title\" style=\"font-weight: bold;font-size: 15pt;\" id=\"receiverName\">&nbsp;&nbsp;收件人信息</h4>\n" +
                      "          <p class=\"weui-media-box__desc\" id=\"receiverAddr\" style=\"font-size: 12pt;\">&nbsp;&nbsp;<font>请点击[地址簿]维护地址</font></p>";
            }
          }
          $("#receive_div").html(str);
        }
      },
      error:function(result){

      },complete:function(){
        $.hideLoading();
      }
    });
  }

  init_data();

  /*地址回写*/
  function set_addr(name,tel,address,lsh,lx)
  {
    if (lx=="1" || lx==1) {
      /* $("#senderName").html("&nbsp;&nbsp;" + name + "&nbsp;" + tel);
       $("#senderAddr").html("&nbsp;&nbsp;" + address);
       $("#senderId").val(lsh);*/
    }
    else{
      $("#receiverName").html("&nbsp;&nbsp;" + name + "&nbsp;" + tel);
      $("#receiverAddr").html("&nbsp;&nbsp;" + address);
      $("#receiverId").val(lsh);
    }
    $.closePopup();
  }
  //地址事件
  $('#receive_div_addrbook').on('click',function () {//收件地址
    a = $("#addrPopup").popup();
    $("#addr_iframe").attr("src",adminUrl+"/h5/addr/query");
  });
  function qrdd(){
    if ($("#receiverId").val()==""){
      alert("请选择地址！");
      return;
    }
    $.showLoading("订单确认中...");
    var jsonData = {
      id: id,
      yw:"1",<!-- 业务：明信片 -->
      ywcs:"2",<!-- 业务参数：1现场 2邮寄 -->
      dz:$("#receiverId").val(),
      timestamp:new Date().getTime()
    };
    var sendStr = {
      data:encrypt_str(JSON.stringify(jsonData),localStorage.getItem("a_h5"),localStorage.getItem("b_h5"))
    };
    $.ajax({
      type:"post",
      url:url+"order_qr",
      data:JSON.stringify(sendStr),
      dataType:"json",
      timeout : 10*1000, //超时时间设置，单位毫秒
      crossDomain: true,
      contentType: 'application/json;charset=UTF-8',
      headers: {
        "token": localStorage.getItem("token_h5")
      },
      beforeSend: function(request) {
        request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
      },
      success:function(result){
        console.info("result:"+JSON.stringify(result));
        if (result.code==0) {
          let rtn = decrypt_str(result.data, localStorage.getItem("a_h5"), localStorage.getItem("b_h5"));
          let d = JSON.parse(rtn);
          //准备去支付界面
          window.location.href=adminUrl+"/h5/pay/info?&yw="+d.yw+"&ywcs="+d.yw+"&id="+d.id+"";
        }
      },
      error:function(result){

      },complete:function(){
        $.hideLoading();
      }
    });
  }
</script>

</body>
</html>
